# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.

# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
#   name = value
#
# (The "=" is optional.)  Whitespace may be used.  Comments are introduced with
# "#" anywhere on a line.  The complete list of parameter names and allowed
# values can be found in the PostgreSQL documentation.
#
# The commented-out settings shown in this file represent the default values.
# Re-commenting a setting is NOT sufficient to revert it to the default value;
# you need to reload the server.
#
# This file is read on server startup and when the server receives a SIGHUP
# signal.  If you edit the file on a running system, you have to SIGHUP the
# server for the changes to take effect, or use "pg_ctl reload".  Some
# parameters, which are marked below, require a server shutdown and restart to
# take effect.
#
# Any parameter can also be given as a command-line option to the server, e.g.,
# "postgres -c log_connections=on".  Some parameters can be changed at run time
# with the "SET" SQL command.
#
# Memory units:  kB = kilobytes        Time units:  ms  = milliseconds
#                MB = megabytes                     s   = seconds
#                GB = gigabytes                     min = minutes
#                                                   h   = hours
#                                                   d   = days


#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------

# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.

#data_directory = 'ConfigDir'   # use data in another directory
          # (change requires restart)
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
          # (change requires restart)
#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
          # (change requires restart)

# If external_pid_file is not explicitly set, no extra PID file is written.
#external_pid_file = '(none)'   # write an extra PID file
          # (change requires restart)


#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '<%= @listen_address %>'    # what IP address(es) to listen on;
          # comma-separated list of addresses;
          # defaults to 'localhost', '*' = all
          # (change requires restart)
port = <%= @port %>        # (change requires restart)
max_connections = <%= @max_connections %>      # (change requires restart)
# Note:  Increasing max_connections costs ~400 bytes of shared memory per
# connection slot, plus lock space (see max_locks_per_transaction).
#superuser_reserved_connections = 3 # (change requires restart)
<% if pg_helper.database_version == "9.2" %>
unix_socket_directory = '<%= @unix_socket_directory %>'   # (change requires restart)
<% else %>
unix_socket_directories = '<%= @unix_socket_directory %>'   # (change requires restart)
<% end %>
#unix_socket_group = ''     # (change requires restart)
#unix_socket_permissions = 0777   # begin with 0 to use octal notation
          # (change requires restart)
#bonjour = off        # advertise server via Bonjour
          # (change requires restart)
#bonjour_name = ''      # defaults to the computer name
          # (change requires restart)

# - Security and Authentication -

#authentication_timeout = 1min    # 1s-600s

# change requires restart
ssl = <%= @ssl %>

# allowed SSL ciphers
<% if @ssl_ciphers %>
ssl_ciphers = '<%= @ssl_ciphers %>'
<% end %>

ssl_cert_file = '<%= @ssl_cert_file %>'
ssl_key_file = '<%= @ssl_key_file %>'
ssl_ca_file = '<%= @ssl_ca_file %>'

<% if @ssl_crl_file %>
ssl_crl_file = '<%= @ssl_crl_file %>'
<% end %>

#ssl_renegotiation_limit = 512MB  # amount of data between renegotiations
#password_encryption = on
#db_user_namespace = off

# Kerberos and GSSAPI
#krb_server_keyfile = ''
#krb_srvname = 'postgres'   # (Kerberos only)
#krb_caseins_users = off

# - TCP Keepalives -
# see "man 7 tcp" for details

#tcp_keepalives_idle = 0    # TCP_KEEPIDLE, in seconds;
          # 0 selects the system default
#tcp_keepalives_interval = 0    # TCP_KEEPINTVL, in seconds;
          # 0 selects the system default
#tcp_keepalives_count = 0   # TCP_KEEPCNT;
          # 0 selects the system default


#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------

# - Memory -

shared_buffers = <%= @shared_buffers %> # min 128kB
          # (change requires restart)
#temp_buffers = 8MB     # min 800kB
#max_prepared_transactions = 0    # zero disables the feature
          # (change requires restart)
# Note:  Increasing max_prepared_transactions costs ~600 bytes of shared memory
# per transaction slot, plus lock space (see max_locks_per_transaction).
# It is not advisable to set max_prepared_transactions nonzero unless you
# actively intend to use prepared transactions.
#max_stack_depth = 2MB      # min 100kB

# - Kernel Resource Usage -

#max_files_per_process = 1000   # min 25
          # (change requires restart)
shared_preload_libraries = '<%= @shared_preload_libraries %>'    # (change requires restart)

# - Cost-Based Vacuum Delay -

#vacuum_cost_delay = 0ms    # 0-100 milliseconds
#vacuum_cost_page_hit = 1   # 0-10000 credits
#vacuum_cost_page_miss = 10   # 0-10000 credits
#vacuum_cost_page_dirty = 20    # 0-10000 credits
#vacuum_cost_limit = 200    # 1-10000 credits

# - Background Writer -

#bgwriter_delay = 200ms     # 10-10000ms between rounds
#bgwriter_lru_maxpages = 100    # 0-1000 max buffers written/round
#bgwriter_lru_multiplier = 2.0    # 0-10.0 multipler on buffers scanned/round

# - Asynchronous Behavior -

#effective_io_concurrency = 1   # 1-1000. 0 disables prefetching


#------------------------------------------------------------------------------
# WRITE AHEAD LOG
#------------------------------------------------------------------------------

# - Settings -

wal_level = <%= @wal_level %>
          # (change requires restart)
#fsync = on       # turns forced synchronization on or off
#wal_sync_method = fsync    # the default is the first option
          # supported by the operating system:
          #   open_datasync
          #   fdatasync (default on Linux)
          #   fsync
          #   fsync_writethrough
          #   open_sync
#full_page_writes = on      # recover from partial page writes
wal_buffers = <%= @wal_buffers %> # -1     # min 32kB, -1 sets based on shared_buffers
          # (change requires restart)
#wal_writer_delay = 200ms   # 1-10000 milliseconds

#commit_delay = 0     # range 0-100000, in microseconds
#commit_siblings = 5      # range 1-1000

<% if pg_helper.database_version != "9.2" %>
min_wal_size = <%= @min_wal_size %>
max_wal_size = <%= @max_wal_size %>

# The number of replication slots to reserve.
max_replication_slots = <%= @max_replication_slots %>

<%# If we don't specify a value for dynamic_shared_memory_type it autodetects, which we want. %>
<%# So only add a value if one is specified %>
<% if @dynamic_shared_memory_type %>
dynamic_shared_memory_type = <%= @dynamic_shared_memory_type %>
<% end %>
<% end %>

# - Archiving -

archive_mode = <%= @archive_mode %>   # allows archiving to be done
        # (change requires restart, also requires 'wal_level' of 'hot_standby' OR 'replica')

#------------------------------------------------------------------------------
# REPLICATION
#------------------------------------------------------------------------------

# - Master Server -

# These settings are ignored on a standby server

max_wal_senders = <%= @max_wal_senders %>
        # (change requires restart)
#wal_sender_delay = 1s    # walsender cycle time, 1-10000 milliseconds
#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
#replication_timeout = 60s  # in milliseconds; 0 disables
#synchronous_standby_names = '' # standby servers that provide sync rep
        # comma-separated list of application_name
        # from standby(s); '*' = all

# - Standby Servers -

# These settings are ignored on a master server

hot_standby = <%= @hot_standby %>
          # (change requires restart)
#wal_receiver_status_interval = 10s # send replies at least this often
          # 0 disables

#------------------------------------------------------------------------------
# QUERY TUNING
#------------------------------------------------------------------------------

# - Planner Method Configuration -

#enable_bitmapscan = on
#enable_hashagg = on
#enable_hashjoin = on
#enable_indexscan = on
#enable_material = on
#enable_mergejoin = on
#enable_nestloop = on
#enable_seqscan = on
#enable_sort = on
#enable_tidscan = on

# - Planner Cost Constants -

#cpu_tuple_cost = 0.01      # same scale as above
#cpu_index_tuple_cost = 0.005   # same scale as above
#cpu_operator_cost = 0.0025   # same scale as above

# - Genetic Query Optimizer -

#geqo = on
#geqo_threshold = 12
#geqo_effort = 5      # range 1-10
#geqo_pool_size = 0     # selects default based on effort
#geqo_generations = 0     # selects default based on effort
#geqo_selection_bias = 2.0    # range 1.5-2.0
#geqo_seed = 0.0      # range 0.0-1.0

# - Other Planner Options -

#default_statistics_target = 100  # range 1-10000
#constraint_exclusion = partition # on, off, or partition
#cursor_tuple_fraction = 0.1    # range 0.0-1.0
#from_collapse_limit = 8
#join_collapse_limit = 8    # 1 disables collapsing of explicit
          # JOIN clauses


#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

<% if @logging_collector %>
logging_collector = <%= @logging_collector %>
<% end %>

# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'

#silent_mode = off      # Run server silently.
          # DO NOT USE without syslog or
          # logging_collector
          # (change requires restart)


# - When to Log -

#client_min_messages = notice   # values in order of decreasing detail:
          #   debug5
          #   debug4
          #   debug3
          #   debug2
          #   debug1
          #   log
          #   notice
          #   warning
          #   error

#log_min_messages = warning   # values in order of decreasing detail:
          #   debug5
          #   debug4
          #   debug3
          #   debug2
          #   debug1
          #   info
          #   notice
          #   warning
          #   error
          #   log
          #   fatal
          #   panic

#log_min_error_statement = error  # values in order of decreasing detail:
          #   debug5
          #   debug4
          #   debug3
          #   debug2
          #   debug1
          #   info
          #   notice
          #   warning
          #   error
          #   log
          #   fatal
          #   panic (effectively off)

# - What to Log -

#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = on
#log_connections = off
#log_disconnections = off
#log_duration = off
#log_error_verbosity = default    # terse, default, or verbose messages
#log_hostname = off
#log_lock_waits = off     # log lock waits >= deadlock_timeout
#log_statement = 'none'     # none, ddl, mod, all
#log_timezone = '(defaults to server environment setting)'


#------------------------------------------------------------------------------
# RUNTIME STATISTICS
#------------------------------------------------------------------------------

# - Query/Index Statistics Collector -

#track_activities = on
#track_counts = on
#track_functions = none     # none, pl, all
track_activity_query_size = <%= @track_activity_query_size %> # (change requires restart)
#update_process_title = on
#stats_temp_directory = 'pg_stat_tmp'


# - Statistics Monitoring -

#log_parser_stats = off
#log_planner_stats = off
#log_executor_stats = off
#log_statement_stats = off


#------------------------------------------------------------------------------
# AUTOVACUUM PARAMETERS
#------------------------------------------------------------------------------

autovacuum_max_workers = <%= @autovacuum_max_workers %> # max number of autovacuum subprocesses
          # (change requires restart)
autovacuum_freeze_max_age = <%= @autovacuum_freeze_max_age %>  # maximum XID age before forced vacuum
          # (change requires restart)
#------------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#------------------------------------------------------------------------------

# - Statement Behavior -

#search_path = '"$user",public'   # schema names
#default_tablespace = ''    # a tablespace name, '' uses the default
#temp_tablespaces = ''      # a list of tablespace names, '' uses
          # only default tablespace
#check_function_bodies = on
#default_transaction_isolation = 'read committed'
#default_transaction_read_only = off
#default_transaction_deferrable = off
#session_replication_role = 'origin'
#vacuum_freeze_min_age = 50000000
#vacuum_freeze_table_age = 150000000
#bytea_output = 'hex'     # hex, escape
#xmlbinary = 'base64'
#xmloption = 'content'

# - Locale and Formatting -

#intervalstyle = 'postgres'
#timezone = '(defaults to server environment setting)'
#timezone_abbreviations = 'Default'     # Select the set of available time zone
          # abbreviations.  Currently, there are
          #   Default
          #   Australia
          #   India
          # You can create your own file in
          # share/timezonesets/.
#extra_float_digits = 0     # min -15, max 3
#client_encoding = sql_ascii    # actually, defaults to database
          # encoding

# - Other Defaults -

#dynamic_library_path = '$libdir'
#local_preload_libraries = ''


#------------------------------------------------------------------------------
# LOCK MANAGEMENT
#------------------------------------------------------------------------------

#deadlock_timeout = 1s
<% if @max_locks_per_transaction %>
max_locks_per_transaction = <%= @max_locks_per_transaction %>   # min 10
          # (change requires restart)
# Note:  Each lock table slot uses ~270 bytes of shared memory, and there are
# max_locks_per_transaction * (max_connections + max_prepared_transactions)
# lock table slots.
<% end %>
#max_pred_locks_per_transaction = 64  # min 10
          # (change requires restart)

#------------------------------------------------------------------------------
# VERSION/PLATFORM COMPATIBILITY
#------------------------------------------------------------------------------

# - Previous PostgreSQL Versions -

#array_nulls = on
#backslash_quote = safe_encoding  # on, off, or safe_encoding
#default_with_oids = off
#escape_string_warning = on
#lo_compat_privileges = off
#quote_all_identifiers = off
#sql_inheritance = on
#standard_conforming_strings = on
#synchronize_seqscans = on

# - Other Platforms and Clients -

#transform_null_equals = off


#------------------------------------------------------------------------------
# ERROR HANDLING
#------------------------------------------------------------------------------

#exit_on_error = off        # terminate session on any error?
#restart_after_crash = on     # reinitialize after backend crash?


#------------------------------------------------------------------------------
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------

#custom_variable_classes = ''   # list of custom variable class names

include 'runtime.conf'
